Scripting > CxScript > FileSystemObject Object > FileSystemObject Methods

FileSystemObject Methods

The FileSystemObject object contains the following methods:

BlobExists

The BlobExists method checks to see if the Blob exists.

Syntax

BlobExists(BlobPath As String) As Boolean

Parameters

Parameter Required Description

BlobPath

Yes

A valid Blob file path, in "site.service\folder\file" format.

Back to top

CheckInBlobFile

The CheckInBlobFile method checks in the specified Blob file.

Syntax

CheckInBlobFile(BlobPath As String) As Boolean

Parameters

Parameter Required Description

BlobPath

Yes

A valid Blob file path, in "site.service\folder\file" format.

Back to top

CheckOutBlobFile

The CheckOutBlobFile method checks out the specified Blob file.

Syntax

CheckOutBlobFile(BlobPath As String) As Boolean

Parameters

Parameter Required Description

BlobPath

Yes

A valid Blob file path, in "site.service\folder\file" format.

Back to top

DeleteFileFromBlob

The DeleteFileFromBlob method deletes the file from the specified Blob path.

Syntax

DeleteFileFromBlob(BlobPath As String) As Boolean

Parameters

Parameter Required Description

BlobPath

Yes

A valid Blob file path, in "site.service\folder\file" format.

Remarks

Return Value: True if the delete was successful, False if it was not.

Errors: If BlobPath is invalid, an error will display.

Example

The following method deletes test.csw from CYGDEMO.BSS and alerts the user.

Sub deleteFile()

Dim objFileSystem

Set objFileSystem = CreateObject("CxScript.FileSystemObject")

 

objFileSystem.DeleteFileFromBlob("CYGDEMO.BSS\TEST\test.CSW")

edtMessageBox.Text = "File Deleted"

End Sub

Back to top

DownloadBlobFile

The DownloadBlobFile method downloads the specified file from the specified Blob service to the current working directory.

Syntax

DownloadBlobFile(BlobSiteService As String, BlobFolder As String, FileName As String, UpdateRulesMask As Integer) As Boolean

Parameters

Parameter Required Description

BlobSiteService

Yes

A valid service name, in "site.service" format.

BlobFolder

Yes

A valid folder name in BlobSiteService.

FileName

Yes

A valid file name in BlobApplication.

UpdateRulesMask

Yes

Used to determine whether the file will be downloaded. Set to 1 to update the rules mask, or 0 to leave it as is. See UpdateRulesMask for more information about this parameter.

Remarks

The file will be downloaded to the current working directory. This depends on what is actually running the script. If you are running the script in CygNet Studio, then that will be the CygNet Studio directory. If the script is running in the HSS, then the HSS service folder will be the download location. Likewise, if you are running the script from the command line, then it will download the file to the current directory.

Return Value: True if the download was successful, False if it was not.

Errors: If BlobSiteService, BlobFolder, or FileName are invalid, an error will display.

Example

The following example downloads MeterTest.csf, and tells the user if it was successful or not.

Sub downloadFile()

Dim objFileSystem

Set objFileSystem = CreateObject("CxScript.FileSystemObject")

 

Dim bRet

bRet = objFileSystem.DownloadBlobFile("CYGDEMO.BSS", "TEST", "MeterTest.csf", 0)

 

If bRet Then

edtMessageBox.Text = "File downloaded successfully"

Else

edtMessageBox.Text = "Error downloading file"

End If

End Sub

Back to top

DownloadBlobFileToDirectory

The DownloadBlobFileToDirectory method downloads the specified file from a Blob service to the destination directory.

Syntax

DownloadBlobFileToDirectory(BlobSiteService As String, BlobFolder As String, FileName As String, DestinationDir As String, UpdateRulesMask As Integer) As Boolean

Parameters

Parameter Required Description

BlobSiteService

Yes

A valid service name, in "site.service" format.

BlobFolder

Yes

A valid folder name in BlobSiteService.

FileName

Yes

A valid file name in BlobApplication.

DestinationDir

Yes

The local file path to download the file to.

UpdateRulesMask

Yes

Used to determine whether the file will be downloaded. Set to 1 to update the rules mask, or 0 to leave it as is. See UpdateRulesMask for more information about this parameter.

Remarks

If DestinationDir does not already exist, its path will be created.

Return Value: True if the download was successful, False if it was not.

Errors: If BlobSiteService, BlobFolder, or FileName are invalid, an error will display.

Example

The following example downloads MeterTest.csf to C:\MyFolder and tells the user if it was successful or not.

Sub downloadFileToDir()

Dim objFileSystem

Set objFileSystem = CreateObject("CxScript.FileSystemObject")

 

Dim bRet

bRet = objFileSystem.DownloadBlobFileToDirectory("CYGDEMO.BSS", _

"TEST", "MeterTest.csf", "C:\MyFolder", 0)

 

If bRet Then

edtMessageBox.Text = "File downloaded successfully"

Else

edtMessageBox.Text = "Error downloading file"

End If

End Sub

Back to top

DownloadFromBlobPath

The DownloadFromBlobPath method downloads the specified file from a Blob service to the current working directory.

Syntax

DownloadFromBlobPath(BlobPath As String, UpdateRulesMask As Integer) As Boolean

Parameters

Parameter Required Description

BlobPath

Yes

A valid Blob file path, in "site.service\folder\file" format.

UpdateRulesMask

Yes

Used to determine whether the file will be downloaded. Set to 1 to update the rules mask, or 0 to leave it as is. See UpdateRulesMask for more information about this parameter.

Remarks

The file will be downloaded to the current working directory. This depends on what is actually running the script. If you are running the script in CygNet Studio, then that will be the CygNet Studio directory. If the script is running in the HSS, then the HSS service folder will be the download location. Likewise, if you are running the script from the command line, then it will download the file to the current directory.

Return Value: True if the download was successful, False if it was not.

Errors: If BlobPath is invalid, an error will display.

Example

The following example downloads MeterTest.csf using its blob path and tells the user if it was successful or not.

Sub downloadFilePath()

Dim objFileSystem

Set objFileSystem = CreateObject("CxScript.FileSystemObject")

 

Dim bRet

bRet = objFileSystem.DownloadFromBlobPath("CYGDEMO.BSS\TEST\MeterTest.csf", 0)

 

If bRet Then

edtMessageBox.Text = "File downloaded successfully"

Else

edtMessageBox.Text = "Error downloading file"

End If

End Sub

Back to top

DownloadFromBlobPathToDirectory

The DownloadFromBlobPathToDirectory method downloads the specified file from a Blob service to the destination directory.

Syntax

DownloadFromBlobPathToDirectory(BlobPath As String, DestinationDir As String, UpdateRulesMask As Integer) As Boolean

Parameters

Parameter Required Description

BlobPath

Yes

A valid Blob file path, in "site.service\folder\file" format.

DestinationDir

Yes

The local file path to download the file to.

UpdateRulesMask

Yes

Used to determine whether the file will be downloaded. Set to 1 to update the rules mask, or 0 to leave it as is. See UpdateRulesMask for more information about this parameter.

Remarks

If DestinationDir does not already exist, its path will be created.

Return Value: True if the download was successful, False if it was not.

Errors: If BlobPath is invalid, an error will display.

Example

The following example downloads MeterTest.csf using its blob path to C:\MyFolder and tells the user if it was successful or not.

Sub downloadFilePathToDir()

Dim objFileSystem

Set objFileSystem = CreateObject("CxScript.FileSystemObject")

 

Dim bRet

bRet = objFileSystem.DownloadFromBlobPathToDirectory( _

"CYGDEMO.BSS\TEST\MeterTest.csf", "C:\MyFolder", 0)

 

If bRet Then

edtMessageBox.Text = "File downloaded successfully"

Else

edtMessageBox.Text = "Error downloading file"

End If

End Sub

Back to top

EnableLibrarian

The EnableLibrarian method enables or disables the librarian state of the specified Blob folder. Also see IsLibrarianEnabled.

Syntax

EnableLibrarian(BlobSiteService As String, Folder As String, Enable As Boolean) As Boolean

Parameters

Parameter Required Description

BlobSiteService

Yes

A valid service name, in "site.service" format.

Folder

Yes

A valid folder name in BlobSiteService.

Enable

Yes

A Boolean value indicating whether or not to enable librarian state for the specified Blob folder.

Back to top

GetBlobFileCheckOutDetails

The GetBlobFileCheckOutDetails method retrieves check out status details for the specified Blob file as a 2-D array.

Syntax

GetBlobFileCheckOutDetails(BlobPath As String, DetailsArray) As Boolean

Parameters

Parameter Required Description

BlobPath

Yes

A valid Blob file path, in "site.service\folder\file" format.

DetailsArray

Yes

An array of check out status details for the Blob file.

Back to top

GetBlobFolderList

The GetBlobFolderList method retrieves a list of all folders for the specified Blob service.

Syntax

GetBlobFolderList(BlobSiteService As String)

Parameters

Parameter Required Description

BlobSiteService

Yes

A valid service name, in "site.service" format.

Remarks

Return Value: An array of folders in BlobSiteService. If BlobSiteService is invalid, an empty array will be returned.

Example

The following example gets all the foldersin CYGDEMO.APPS and displays them in a list box.

Sub getBlobFolderList()

Dim objFileSystem

Set objFileSystem = CreateObject("CxScript.FileSystemObject")

 

Dim arrPathList, item

arrPathList = objFileSystem.GetBlobFolderList("CYGDEMO.APPS")

lstBlob.ResetContent

For Each item In arrPathList

lstBlob.AddString(item)

Next

End Sub

Back to top

GetBlobFileListByFolder

The GetBlobFileListByFolder method retrieves a list of all file names in the specified Blob folder.

Syntax

GetBlobFileListByFolder(BlobSiteService As String, Folder As String)

Parameters

Parameter Required Description

BlobSiteService

Yes

A valid service name, in "site.service" format.

Folder

Yes

A valid folder name in BlobSiteService.

Remarks

Return Value: An array of names for all Blob files in the folder. If BlobSiteService or Folder is invalid, an empty array will be returned.

Example

The following example gets all files in the HELP folderand displays them in a list box.

Sub getBlobByFolder()

Dim objFileSystem

Set objFileSystem = CreateObject("CxScript.FileSystemObject")

 

Dim arrPathList, item

arrPathList = objFileSystem.GetBlobFileListByFolder("CYGDEMO.APPS", "HELP")

lstBlob.ResetContent

For Each item In arrPathList

lstBlob.AddString(item)

Next

End Sub

Back to top

GetBlobPathList

The GetBlobPathList method retrieves a list of all Blob file paths in the specified Blob service.

Syntax

GetBlobPathList(BlobSiteService As String)

Parameters

Parameter Required Description

BlobSiteService

Yes

A valid service name, in "site.service" format.

Remarks

Return Value: An array of file paths for all blob files in the service. If BlobSiteService is invalid, an empty array will be returned.

Example

The following example gets the file paths for CYGDEMO.BSS and displays them in a list box.

Sub getBlobPaths()

Dim objFileSystem

Set objFileSystem = CreateObject("CxScript.FileSystemObject")

 

Dim arrPathList, item

arrPathList = objFileSystem.GetBlobPathList("CYGDEMO.BSS")

lstBlob.ResetContent

For Each item In arrPathList

lstBlob.AddString(item)

Next

End Sub

Back to top

IsBlobFileCheckedOut

The IsBlobFileCheckedOut method checks if the specified Blob file is checked out.

Syntax

IsBlobFileCheckedOutByAnotherUser(BlobPath As String) As Boolean

Parameters

Parameter Required Description

BlobPath

Yes

A valid Blob file path, in "site.service\folder\file" format.

Back to top

IsBlobFileCheckedOutByAnotherUser

The IsBlobFileCheckedOutByAnotherUser method checks if the specified Blob file is checked out by another user.

Syntax

IsBlobFileCheckedOutByAnotherUser(BlobPath As String) As Boolean

Parameters

Parameter Required Description

BlobPath

Yes

A valid Blob file path, in "site.service\folder\file" format.

Back to top

IsBlobFileCheckedOutByCurrentUser

The IsBlobFileCheckedOutByCurrentUser method checks if the specified Blob file is checked out by the current user.

Syntax

IsBlobFileCheckedOutByCurrentUser(BlobPath As String) As Boolean

Parameters

Parameter Required Description

BlobPath

Yes

A valid Blob file path, in "site.service\folder\file" format.

Back to top

IsLibrarianEnabled

The IsLibrarianEnabled method returns the librarian enabled state of the specified Blob folder. See also EnableLibrarian.

Syntax

IsLibrarianEnabled(BlobSiteService As String, Folder As String) As Boolean

Parameters

Parameter Required Description

BlobSiteService

Yes

A valid service name, in "site.service" format.

Folder

Yes

A valid folder name in BlobSiteService.

Back to top

IsValidBlobPath

The IsValidBlobPath checks if the format for the Blob path is valid.

Syntax

IsValidBlobPath(BlobPath As String) As Boolean

Parameters

Parameter Required Description

BlobPath

Yes

A valid Blob file path, in "site.service\folder\file" format.

Back to top

ReadBlobString

The ReadBlobString method reads the contents of the specified Blob file to the provided string. Optionally, you can include a Blob file in a BSS on a different domain.

Syntax

ReadBlobString(BlobPath As String) As String

Parameters

Parameter Required Description

BlobPath

Yes

A valid Blob file path, in "site.service\folder\file" format.

You can specify a domain for a BSS on another domain, as necessary: "[10003]site.service\folder\file"

Remarks

Return Value: A string containing the contents of the file.

Errors: If BlobPath is invalid, an error will display.

Example

The following example reads the contents of a text file from CYGDEMO.BSS on domain 10003.

Sub readString()

Dim objFileSystem

Set objFileSystem = CreateObject("CxScript.FileSystemObject")

 

Dim strRet

strRet = objFileSystem.ReadBlobString("[10003]CYGDEMO.BSS\INCLUDE\READTEST.TXT")

WScript.Echo strRet

End Sub

Back to top

UndoCheckOut

The UndoCheckOut method revokes a check out for a Blob file. Optionally allows a user with admin access to force an undo action against another user's checkout.

Syntax

UndoCheckOut(BlobPath As String, ForceUndo As Boolean) As Boolean

Parameters

Parameter Required Description

BlobPath

Yes

A valid Blob file path, in "site.service\folder\file" format.

ForceUndo

Yes  
Back to top

UploadFileToBlob

The UploadFileToBlob method uploads the specified file from a local source directory to the specified Blob folder.

Syntax

UploadFileToBlob(BlobSiteService As String, BlobFolder As String, SourceFileName As String, SourceFileDirectory As String, UpdateRulesMask As Integer) As Boolean

Parameters

Parameter Required Description

BlobSiteService

Yes

A valid service name, in "site.service" form.

BlobFolder

Yes

A valid foldername in BlobSiteService.

SourceFileName

Yes

The file name of the file to copy.

SourceFileDirectory

Yes

The directory of the file to copy.

UpdateRulesMask

Yes

Used to determine whether the file will be uploaded. Set to 1 to update the rules mask, or 0 to leave it as is. See UpdateRulesMask for more information about this parameter.

Remarks

Return Value: A Boolean indicating if the method succeeded.

Errors: If any of the properties are invalid, an error will display.

Example

The following example uploads C:\MyFolder\TestScreen.csf to CYGDEMO.BSS\TEST and tells the user whether or not the operation was successful.

Sub uploadFile()

Dim objFileSystem

Set objFileSystem = CreateObject("CxScript.FileSystemObject")

 

Dim bRet

bRet = objFileSystem.UploadFileToBlob("CYGDEMO.BSS", "TEST", _

"TestScreen.csf", "C:\MyFolder", 0)

 

If bRet Then

edtMessageBox.Text = "File upload successful"

Else

edtMessageBox.Text = "Error uploading file"

End If

End Sub

Back to top

UploadFileToBlobPath

The UploadFileToBlobPath method uploads the specified file from a local source directory to the specified Blob path.

Syntax

UploadFileToBlobPath(BlobPath As String, SourceFileName As String, SourceFileDirectory As String, UpdateRulesMask As Integer) As Boolean

Parameters

Parameter Required Description

BlobPath

Yes

A valid Blob file path, in "site.service\folder\file" format.

SourceFileName

Yes

The file name of the file to copy.

SourceFileDirectory

Yes

The file directory of the file to copy.

UpdateRulesMask

Yes

Used to determine whether the file will be uploaded. Set to 1 to update the rules mask, or 0 to leave it as is.

Remarks

Return Value: A Boolean indicating if the method succeeded.

Errors: If any of the properties are invalid, an error will display.

Example

The following example uploads C:\MyFolder\uploadtest.txt to CYGDEMO.BSS\TEST\uploadtest.txt and tells the user whether or not the operation was successful.

Sub uploadFilePath()

Dim objFileSystem

Set objFileSystem = CreateObject("CxScript.FileSystemObject")

 

Dim bRet

bRet = objFileSystem.UploadFileToBlobPath("CYGDEMO.BSS\TEST\file.txt", _

"uploadtest.txt", "C:\MyFolder", 0)

 

If bRet Then

edtMessageBox.Text = "File upload successful"

Else

edtMessageBox.Text = "Error uploading file"

End If

End Sub

Back to top

WriteBlobString

The WriteBlobString method writes the provided string to the specified Blob path.

Syntax

WriteBlobString(BlobPath As String, Value As String) As Boolean

Parameters

Parameter Required Description

BlobPath

Yes

A valid Blob file path, in "site.service\folder\file" format.

Value

Yes

The information to store in the file.

Remarks

If any folders in BlobPath do not exist, they will be created.

Return Value: A Boolean indicating if the method succeeded.

Example

The following example writes information to CYGDEMO.BSS\WRITE\Stuff.txt and tells the user whether or not the operation was successful.

Sub writeBlob()

Dim objFileSystem

Set objFileSystem = CreateObject("CxScript.FileSystemObject")

 

Dim bRet

bRet = objFileSystem.WriteBlobString("CYGDEMO.BSS\Write\Stuff.txt", "text text")

 

If bRet Then

edtMessageBox.Text = "File upload successful"

Else

edtMessageBox.Text = "Error uploading file"

End If

End Sub

Back to top

Let us know how we can improve this topic.

CygNet at weatherford.com

© 2020 Weatherford. All rights reserved.